-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
report a command system origin in case of panic #2222
Conversation
ca9467f
to
4c87867
Compare
commands: Vec<Box<dyn Command>>, | ||
pub(crate) commands: Vec<Box<dyn Command>>, | ||
#[cfg(feature = "command_panic_origin")] | ||
pub(crate) system_name: Option<Cow<'static, str>>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be Option<_>
?
inside fn init
system_name
is always set as Some.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the struct CommandQueue
is pub and can be built using default()
(done in LightsNode
and in RenderResourcesNode
). In those case a None is better than an empty string I think.
Though with the field behind a feature it's less of an issue I guess
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we just impl Default for CommandQueue
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unless it's actually possible for it to be None
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can be None
!
Co-authored-by: bjorn3 <[email protected]>
The new feature also needs to be mentioned in the ./docs/cargo_features.md file. |
@mockersf .on_err(CommandErrorHandler::panic()) which, I have a feeling will be few and far between. It's probably a better approach to have the struct CommandArgs<'a> {
world: &'a mut World,
system_name: Cow<'static, str>,
}
trait Command {
fn write(self: Box<Self>, args: CommandArgs);
} So that way all commands (and error handlers) can have the system name correctly propagated to them? |
I think this'll definitely to be looked at after #2241 has been merged, moved it to draft
Or having the system name in the |
Yep, it'll be there to. |
related to #1743 and #2219
Add a new feature
bevy_command_panic_origin
. If it is enabled, the command system origin will be logged in case of panic when applying it.This is not meant to be a final feature with nice UX but more a stepping stone for adding proper result handling of commands. But it can be useful as is, and adding error to all commands is a much larger change #2004